<?php

require_once '../include/common.inc.php';

if (!checkAdmin()) {
    header("LOCATION:index.php");
    exit;
}

$menu_index = 2;
$page_title = 'JANSEN';
$guide_message = 'Customer | Send confirmation email';

getMyParam('uid');
getMyParam('act');


$sql = "SELECT `username`, `password2`, `firstname`, `email`, `status` FROM `user` WHERE `id` = $uid";
$user_info = $db->get_one($sql);

if (empty($user_info)) {
    header("Location:c_customer_list.php");
    exit;
}

if ($act == "send") {
	if ($user_info['status'] == 1) {
	    if ($user_info['email'] == '') {
	        echo "<script>alert('Email not exist');location.href='c_customer_list.php'</script>";
	        exit;
	    }
	    require_once '../mail/temporary.php';
	    sendmail($from_name,$from_email,$to_name,$to_email,$subject,$content);
	    echo "<script>alert('Confirmation email have send');location.href='c_customer_list.php'</script>";
	} elseif ($user_info['status'] == 2) {
	    if ($user_info['email'] == '') {
	        echo "<script>alert('Email not exist');location.href='c_customer_list.php'</script>";
	        exit;
	    }
		require_once '../mail/permanent.php';
	    sendmail($from_name,$from_email,$to_name,$to_email,$subject,$content);
	    echo "<script>alert('Confirmation email have send');location.href='c_customer_list.php'</script>";
	} else {
		header("Location:c_customer_list.php");
	}
    
    exit;
}

require_once PrintEot('a_header');
require_once PrintEot('a_c_confirm_email');
require_once PrintEot('a_footer');

?>